import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // HR在redis中的key值
    hr_redis_token: '',
    // 当前登陆的 HR
    hr: {},
    hr_id: -1
  },
  getters: {
    get_token(state) {
      return window.localStorage.getItem("hr_token")
    },
    hr(state) {
      return JSON.parse(window.localStorage.getItem("hr"))
    },
    hr_id(state) {
      return window.localStorage.getItem("hr_id")
    }
  },
  mutations: {
    set_token(state, token) {
      window.localStorage.setItem("hr_token", token)
      state.hr_redis_token = token
    },
    setHR(state, hr_) {

      window.localStorage.setItem("hr", JSON.stringify(hr_))
      state.hr = hr_
    },
    setHrId(state, id) {

      window.localStorage.setItem("hr_id", id)
      state.hr_id = id
    }
  },
  actions: {

  },
  modules: {
  }
})
